<?php
/**
 * MUser 
 * - Define class MUser
 * @author ANHTAM
 * @since 1.1 - Sep 27, 2011
 * $Id: $
 */
include_once(DOCUMENT_ROOT . "/lib/core/BaseProcess.class.php");
class MUser extends BaseProcess {
	public function __construct() {
		parent::__construct("m_user");
		$this->primaryKeyName = "id";
	}
	
	public function checkLogin($user, $pass) {
		$confiden = array('nickname' => $user, 'pass' => $pass);
		return $this->getOneByAttr($confiden);
	}
	
	public function checkUser($user) {
		$sql = "SELECT count(*) as count_id FROM " . $this->tableName . " WHERE nickname = '" . mysql_real_escape_string($user) . "'";
		$rs = $this->execute($sql, ADODB_FETCH_ASSOC);
		return ($rs && $rs->fields['count_id'] > 0) ? false : true;
	}
	
	public function checkEmail($email) {
		$sql = "SELECT count(*) as count_id FROM " . $this->tableName . " WHERE email = '" . mysql_real_escape_string($email) . "'";
		$rs = $this->execute($sql, ADODB_FETCH_ASSOC);
		return ($rs && $rs->fields['count_id'] > 0) ? false : true;
	}
}
?>